<template>
    <div class="gift-all" :class="{content_main:!gameId}">
        <div v-if="!isSearchRes">
            <div class="g-title">
                <h3 v-if="gameId">{{ $t('All_gift_packages') }}</h3>
                <h4 v-if="!gameId">{{ $t('All_gift_packages') }}</h4>
            </div>
            <ul class="list">
                <li :class="{width:gameId}" v-for="item in freeGiftList" :key="item.id">
                    <a @click="openBox(true,item)" href="javascript:;" class="gift-box">
                        <div class="img">
                            <img :src="$baseUrl+item.icon">
                        </div>
                        <div class="info">
                            <h5>{{ item.gift_name }}</h5>
                            <p>{{ item.title }}</p>
                            <p :title="item.gift_content">{{ item.gift_content }}</p>
                            <div class="price-box">
                                <span v-show="item.gift_type == 1" class="price-old">{{ $t('price') }}<b>{{ item.integral }}</b></span>
                                <span v-show="item.gift_type == 0" class="price-old">{{ $t('price') }}<b>0</b></span>
                                <em v-show="item.gift_type == 1">{{ $t('integral_redemption') }}</em> 
                                <em v-show="item.gift_type == 0">{{ $t('free_receive') }}</em> 
                            </div>
                            <div class="btn" v-if="!item.gift_type">{{ $t('free_receive') }}</div>
                            <div class="btn" v-if="item.gift_type">{{ $t('integral_redemption') }}</div>
                        </div>
                    </a>
                </li>
                <li v-if="!freeGiftList.length">{{ $t('No_gift_packages') }}</li>
            </ul>
        </div>


        <div v-if="isSearchRes">
            <div class="g-title">
                <h4>{{ $t('searchRes') }}</h4>
            </div>
            <ul class="list">
                <li :class="{width:gameId}" v-for="item in searchRes" :key="item.id">
                    <a @click="openBox(true,item)" href="javascript:;" class="gift-box">
                        <div class="img">
                            <img :src="$baseUrl+item.icon">
                        </div>
                        <div class="info">
                            <h5>{{ item.gift_name }}</h5>
                            <p>{{ item.title }}</p>
                            <p :title="item.gift_content">{{ item.gift_content }}</p>
                            <div class="price-box">
                                <span v-show="item.gift_type == 1" class="price-old">{{ $t('price') }}<b>{{ item.integral }}</b></span>
                                <span v-show="item.gift_type == 0" class="price-old">{{ $t('price') }}<b>0</b></span>
                                <em v-show="item.gift_type == 1">{{ $t('integral_redemption') }}</em> 
                                <em v-show="item.gift_type == 0">{{ $t('free_receive') }}</em> 
                            </div>
                            <div class="btn" v-if="!item.gift_type">{{ $t('free_receive') }}</div>
                            <div class="btn" v-if="item.gift_type">{{ $t('integral_redemption') }}</div>
                        </div>
                    </a>
                </li>
                <p class="isNull isNull_notext" v-if="!searchRes.length">{{ $t('empty') }}</p>
            </ul>
        </div>
    </div>
</template>

<script setup>

    const props = defineProps(['detailWapper_farther','freeGiftList','gameId','searchRes','isSearchRes']);
    const openBox = (type,item) => { //调用父组件方法打开礼包详情
        props.detailWapper_farther(type,item)
    }
    console.log(props.freeGiftList,'5555');
</script>

<style lang="less" scoped>
.gift-all {
    .width{
        width: calc(100%/3);
    }
    // min-height: 900px;
    position: relative;
    padding-top: 90px;
    padding-bottom: 20px;
    position: relative;
    h4,h3 {
        font-size: 24px;
        line-height: 36px;
        color: #333;
        font-weight: 400;
    }
    h3 {
        font-size: 18px;
        line-height: 36px;
        color: #333;
        font-weight: 400;
    }
    h3:before {
        content: '';
        float: left;
        margin-top: 9px;
        margin-right: 16px;
        z-index: 2;
        background: #00ace6;
        width: 4px;
        height: 18px;
    }
    h4:before {
        content: '';
        float: left;
        margin-top: 6px;
        margin-right: 16px;
        z-index: 2;
        background: #00ace6;
        width: 4px;
        height: 24px;
    }
    li {
        margin-top: 20px;
        list-style: none;
        a{
            text-decoration: none;
        }
        font-size: 14px;
        width: 20%;
        display: inline-block;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        margin-bottom: 20px;
        vertical-align: middle;
        .gift-box {
            margin: 0 auto;
            display: block;
            border-radius: 4px;
            -webkit-transition: all .3s;
            transition: all .3s;
            width: 200px;
            height: 300px;
            -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .1);
            box-shadow: 0 1px 2px rgba(0, 0, 0, .1);
            border-radius: 4px;
            border: solid 1px #ededed;
            position: relative;

            .img {
                width: 100px;
                height: 100px;
                border-radius: 8px;
                position: relative;
                overflow: hidden;
                background-repeat: no-repeat;
                background-position: center;
                -webkit-box-sizing: border-box;
                box-sizing: border-box;
                display: block;
                margin: 30px auto 18px;
                img {
                    display: block;
                    width: 100%;
                    height: 100%;
                    position: absolute;
                    left: 50%;
                    top: 50%;
                    -webkit-transform: translate(-50%, -50%);
                    -ms-transform: translate(-50%, -50%);
                    transform: translate(-50%, -50%);
                }
            }

            .info {
                overflow: hidden;
                min-height: 110px;
                -webkit-box-sizing: border-box;
                box-sizing: border-box;
                text-align: center;
                .btn {
                    font-size: 14px;
                    border-radius: 15px;
                    border: 1px solid #fff;
                    // width: 92px;
                    min-width: 150px;
                    height: 32px;
                    line-height: 32px;
                    margin-top: 0;
                    color: #fff;
                    display: inline-block;
                }

                h5 {
                    font-size: 16px;
                    color: #333;
                    font-weight: 400;
                    line-height: 16px;
                    margin-bottom: 10px;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                    -webkit-transition: color .2s;
                    transition: color .2s;
                }
                p {
                    padding: 0 16px;
                    font-size: 12px;
                    color: #99a2aa;
                    line-height: 1.2;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                    margin-bottom: 16px;
                    // height: 28px;
                    word-wrap: break-word;
                }
                .price-box {
                    font-size: 0;
                    position: absolute;
                    bottom: 0;
                    left: 0;
                    width: 100%;
                    margin-bottom: 30px;
                    em {
                        color: #fb7299;
                        margin-right: 10px;
                        font-size: 12px;
                        line-height: 1;
                        display: block;
                    }
                    .price-old {
                        height: 12px;
                        font-size: 12px;
                        line-height: 1;
                        color: #99a2aa;
                        padding: 0 4px;
                        position: relative;
                        display: inline-block;
                        vertical-align: middle;
                        margin-bottom: 10px;
                        b {
                            font-weight: 700;
                            font-family: Arial;
                            font-size: 12px;
                            display: inline-block;
                            vertical-align: middle;
                            position: relative;
                            margin-left: 5px;
                        }
                    }
                    // .price-old:before {
                    //     content: '';
                    //     position: absolute;
                    //     width: 100%;
                    //     height: 1px;
                    //     background-color: #99a2aa;
                    //     bottom: 4px;
                    //     left: 0;
                    // }
                }
            }
        }
    }
    li:hover{
        .info{
            h5,p{
                color: #fff;
            }
            p{
                // height: 58px;
            }
        }
        a{
            background-color: #24ade4;
            border: solid 1px transparent;
            -webkit-box-shadow: 0 6px 12px 0 rgba(36, 173, 228, .4);
            box-shadow: 0 6px 12px 0 rgba(36, 173, 228, .4);
        }
        .price-box{
            display: none;
        }
        
        .btn{
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translate(-50%);
        }
    }
    }
</style>